$(function () {
    var getParams = getArgs();
    var currentHotel = getParams.hotel;
    var orderNumber = getParams.no;
    var orderHotel = getParams.orderHotel;
    var couponGetNo = getParams.coupon;
    toastr.options = {
        "newestOnTop": false,
        "timeOut": 1500,
        "extendedTimeOut": 0,
        "escapeHtml": true,
        "positionClass": "toast-bottom-center"
    };
    if (currentHotel === undefined || currentHotel === '') {
        toastr.error(lang('toastr.grogshop'));
        return;
    }     
    var verifyContent = $('.verify-content');
    verifyContent.on('click','.getCode', function (e) {
        var submitBtn = $(this);
        var params = {};
        params.mobile = $('#requestMobile').val();
        params.areaCode = $('.type-list-areaCode span').text().trim();
        if(params.mobile == ''){
            toastr.error(lang('tip.mobileWrite'))
            return false;
        }
        ajaxRequest('/Home/Pay/smsVipPayVcode', params, 'post', function (data) {
            timeDisplay(submitBtn, 60);
        }, function (error) {
            toastr.error(typeof error.responseJSON === 'undefined' ? lang('tip.server') : error.responseJSON.info);
        });
    });     
    $('#paybtn').on('click',function(e){
        e.stopPropagation(); 
        var params = {};
        var ret = /^\d{4}$/;
        params.hotel = currentHotel;
        params.mobile = $('#requestMobile').val();
        params.areaCode = $('.type-list-areaCode span').text().trim();
        params.vcode = $('#requestRecharge').val();
        params.orderNumber = orderNumber;
        params.orderHotel = orderHotel;
        params.couponGetNo = couponGetNo;
        if(params.mobile == ''){
            toastr.error(lang('tip.mobileWrite'))
            return false;
        }
        if(params.vcode == ''){
            toastr.error(lang('tip.messageNull'))
            return false;
        }
        if(!ret.test(params.vcode)){
            toastr.error(lang('tip.message'))
            return false;
        }
        ajaxRequest('/Home/Pay/vipCardPay',params, 'post', function (data) {
            window.location.href = "/Home/OrderPage/index?hotel=" + currentHotel + "&no=" + orderNumber;        
        }, function(error){
            toastr.error(typeof error.responseJSON === 'undefined' ? lang('tip.server') : error.responseJSON.info);
        });  
    });         
});
